﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Net;

namespace Qadir.MVC.Streamline
{
    /// <summary>
    /// A visual representation of data that is produced for the end-user.
    /// </summary>
    [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = true)]
    public sealed class ViewAttribute : Attribute
    {
        /// <summary>
        /// The unique name of this view.
        /// </summary>
        public string Name;

        /// <summary>
        /// A visual representation of data that is produced for the end-user.
        /// </summary>
        /// <param name="Name">The unique name of this view.</param>
        /// <param name="Make">A method to be called when showing this view.</param>
        public ViewAttribute(string Name)
        {
            this.Name = Name;
        }
    }

    /// <summary>
    /// Processes given input and produces a rendering of a view.
    /// </summary>
    /// <param name="args">Input arguments to generate this view.</param>
    public delegate void MakeView(IModel model, Dictionary<string, object> args);

    /// <summary>
    /// An exception that occurs when dealing with a Qadir MVC View.
    /// </summary>
    [Serializable]
    public class ViewException : Exception
    {
        public ViewException() { }
        public ViewException(string message) : base(message) { }
        public ViewException(string message, Exception inner) : base(message, inner) { }
        protected ViewException(
          System.Runtime.Serialization.SerializationInfo info,
          System.Runtime.Serialization.StreamingContext context)
            : base(info, context) { }
    }
}
